package com.zheng.hospital.common.exception;

import com.zheng.hospital.common.result.CommonResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public CommonResult error(Exception e) {
        e.printStackTrace();
        return CommonResult.fail();
    }

    @ExceptionHandler(HospitalException.class)
    @ResponseBody
    public CommonResult error(HospitalException e) {
        e.printStackTrace();
        return CommonResult.fail();
    }
}
